import Page
from Page import Yomi
from Base.Base import Base
from selenium.webdriver.common.by import By


class YomiCarControlPage(Base):
    """
    语音训练车控预设

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的返回键
        self.car_back_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format('ivBack'))

        # 左侧的返回键
        self.car_home_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format('ivHome'))

        # 车控标题
        self.car_control_title_text = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format("tv_title"))

        # 车控名称
        self.car_control_name_icon = (By.XPATH, Yomi.car_control_name_icon.format(""))

        # 车控开关
        self.car_control_switch_btn = (By.XPATH, Yomi.car_control_switch_btn.format(""))

        # 整车温度
        self.car_control_temperature_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format("tv_temperature"))

        # 车窗预设
        self.car_control_window_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format("tv_window"))

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.car_back_btn)

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.car_home_btn)

    def get_control_title(self):
        """
        获取车控列表标题

        :return:获取元素
        """
        return self.find_element_o(self.car_control_title_text)

    def get_control_name(self, index=1):
        """
        获取车控名称

        :return:获取元素
        """
        self.car_control_name_icon = (By.XPATH, Yomi.car_control_name_icon.format(index))
        return self.find_element_o(self.car_control_name_icon)

    def get_control_switch(self, index=1):
        """
        获取车控开关

        :return:获取元素
        """
        self.car_control_switch_btn = (By.XPATH, Yomi.car_control_switch_btn.format(index))
        return self.find_element_o(self.car_control_switch_btn)

    def get_control_temperature(self):
        """
        获取整车温度

        :return:获取元素
        """
        # self.car_control_temperature_btn = (By.XPATH, Yomi.car_control_temperature_btn.format(index))
        return self.find_element_o(self.car_control_temperature_btn)

    def get_control_window(self):
        """
        获取车窗预设

        :return:获取元素
        """
        # self.car_control_window_btn = (By.XPATH, Yomi.car_control_window_btn.format(index))
        return self.find_element_o(self.car_control_window_btn)

    def click_control_name(self, index=1):
        """
        点击车控名称

        :return:None
        """
        self.car_control_name_icon = (By.XPATH, Yomi.car_control_name_icon.format(index))
        self.click_element(self.car_control_name_icon)

    def click_control_switch(self, index=1):
        """
        点击车控开关

        :return:None
        """
        self.car_control_switch_btn = (By.XPATH, Yomi.car_control_switch_btn.format(index))
        self.click_element(self.car_control_switch_btn)

    def click_control_temperature(self):
        """
        点击整车温度

        :return:获取元素
        """
        # self.car_control_temperature_btn = (By.XPATH, Yomi.car_control_temperature_btn.format(index))
        self.click_element(self.car_control_temperature_btn)

    def click_control_window(self):
        """
        获取车窗预设

        :return:获取元素
        """
        # self.car_control_window_btn = (By.XPATH, Yomi.car_control_window_btn.format(index))
        self.click_element(self.car_control_window_btn)

    def is_display_yomi_car_control(self):
        """
        查看是否进入车控页

        :return:
        """
        return self.is_display(self.car_control_title_text)
